.class public Lnet/oauth/server/HttpRequestMessage;
.super Lnet/oauth/OAuthMessage;
.source "HttpRequestMessage.java"


# instance fields
.field private final request:Ljavax/servlet/http/HttpServletRequest;


# direct methods
.method public constructor <init>(Ljavax/servlet/http/HttpServletRequest;Ljava/lang/String;)V
    .locals 2
    .parameter "request"
    .parameter "URL"

    .prologue
    .line 38
    invoke-interface {p1}, Ljavax/servlet/http/HttpServletRequest;->getMethod()Ljava/lang/String;

    move-result-object v0

    invoke-static {p1}, Lnet/oauth/server/HttpRequestMessage;->getParameters(Ljavax/servlet/http/HttpServletRequest;)Ljava/util/List;

    move-result-object v1

    invoke-direct {p0, v0, p2, v1}, Lnet/oauth/OAuthMessage;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Collection;)V

    .line 39
    iput-object p1, p0, Lnet/oauth/server/HttpRequestMessage;->request:Ljavax/servlet/http/HttpServletRequest;

    .line 40
    invoke-virtual {p0}, Lnet/oauth/server/HttpRequestMessage;->getHeaders()Ljava/util/List;

    move-result-object v0

    invoke-static {p1, v0}, Lnet/oauth/server/HttpRequestMessage;->copyHeaders(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Collection;)V

    .line 41
    return-void
.end method

.method private static copyHeaders(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Collection;)V
    .locals 5
    .parameter "request"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljavax/servlet/http/HttpServletRequest;",
            "Ljava/util/Collection",
            "<",
            "Ljava/util/Map$Entry",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;>;)V"
        }
    .end annotation

    .prologue
    .line 56
    .local p1, into:Ljava/util/Collection;,"Ljava/util/Collection<Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;>;"
    invoke-interface {p0}, Ljavax/servlet/http/HttpServletRequest;->getHeaderNames()Ljava/util/Enumeration;

    move-result-object v1

    .line 57
    .local v1, names:Ljava/util/Enumeration;,"Ljava/util/Enumeration<Ljava/lang/String;>;"
    if-eqz v1, :cond_1

    .line 58
    :cond_0
    invoke-interface {v1}, Ljava/util/Enumeration;->hasMoreElements()Z

    move-result v3

    if-eqz v3, :cond_1

    .line 59
    invoke-interface {v1}, Ljava/util/Enumeration;->nextElement()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    .line 60
    .local v0, name:Ljava/lang/String;
    invoke-interface {p0, v0}, Ljavax/servlet/http/HttpServletRequest;->getHeaders(Ljava/lang/String;)Ljava/util/Enumeration;

    move-result-object v2

    .line 61
    .local v2, values:Ljava/util/Enumeration;,"Ljava/util/Enumeration<Ljava/lang/String;>;"
    if-eqz v2, :cond_0

    .line 62
    :goto_0
    invoke-interface {v2}, Ljava/util/Enumeration;->hasMoreElements()Z

    move-result v3

    if-eqz v3, :cond_0

    .line 63
    new-instance v4, Lnet/oauth/OAuth$Parameter;

    invoke-interface {v2}, Ljava/util/Enumeration;->nextElement()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    invoke-direct {v4, v0, v3}, Lnet/oauth/OAuth$Parameter;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {p1, v4}, Ljava/util/Collection;->add(Ljava/lang/Object;)Z

    goto :goto_0

    .line 68
    .end local v0           #name:Ljava/lang/String;
    .end local v2           #values:Ljava/util/Enumeration;,"Ljava/util/Enumeration<Ljava/lang/String;>;"
    :cond_1
    return-void
.end method

.method public static getParameters(Ljavax/servlet/http/HttpServletRequest;)Ljava/util/List;
    .locals 14
    .parameter "request"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljavax/servlet/http/HttpServletRequest;",
            ")",
            "Ljava/util/List",
            "<",
            "Lnet/oauth/OAuth$Parameter;",
            ">;"
        }
    .end annotation

    .prologue
    .line 71
    new-instance v8, Ljava/util/ArrayList;

    invoke-direct {v8}, Ljava/util/ArrayList;-><init>()V

    .line 72
    .local v8, list:Ljava/util/List;,"Ljava/util/List<Lnet/oauth/OAuth$Parameter;>;"
    const-string v12, "Authorization"

    invoke-interface {p0, v12}, Ljavax/servlet/http/HttpServletRequest;->getHeaders(Ljava/lang/String;)Ljava/util/Enumeration;

    move-result-object v4

    .line 73
    .local v4, headers:Ljava/util/Enumeration;,"Ljava/util/Enumeration<Ljava/lang/String;>;"
    :cond_0
    if-eqz v4, :cond_2

    invoke-interface {v4}, Ljava/util/Enumeration;->hasMoreElements()Z

    move-result v12

    if-eqz v12, :cond_2

    .line 74
    invoke-interface {v4}, Ljava/util/Enumeration;->nextElement()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    .line 75
    .local v3, header:Ljava/lang/String;
    invoke-static {v3}, Lnet/oauth/OAuthMessage;->decodeAuthorization(Ljava/lang/String;)Ljava/util/List;

    move-result-object v12

    invoke-interface {v12}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v5

    .local v5, i$:Ljava/util/Iterator;
    :cond_1
    :goto_0
    invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z

    move-result v12

    if-eqz v12, :cond_0

    invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v10

    check-cast v10, Lnet/oauth/OAuth$Parameter;

    .line 77
    .local v10, parameter:Lnet/oauth/OAuth$Parameter;
    const-string v12, "realm"

    invoke-virtual {v10}, Lnet/oauth/OAuth$Parameter;->getKey()Ljava/lang/String;

    move-result-object v13

    invoke-virtual {v12, v13}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v12

    if-nez v12, :cond_1

    .line 78
    invoke-interface {v8, v10}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    .line 82
    .end local v3           #header:Ljava/lang/String;
    .end local v5           #i$:Ljava/util/Iterator;
    .end local v10           #parameter:Lnet/oauth/OAuth$Parameter;
    :cond_2
    invoke-interface {p0}, Ljavax/servlet/http/HttpServletRequest;->getParameterMap()Ljava/util/Map;

    move-result-object v12

    invoke-interface {v12}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v12

    invoke-interface {v12}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v5

    :cond_3
    invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z

    move-result v12

    if-eqz v12, :cond_4

    invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    .local v1, e:Ljava/lang/Object;
    move-object v2, v1

    .line 83
    check-cast v2, Ljava/util/Map$Entry;

    .line 84
    .local v2, entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;[Ljava/lang/String;>;"
    invoke-interface {v2}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v9

    check-cast v9, Ljava/lang/String;

    .line 85
    .local v9, name:Ljava/lang/String;
    invoke-interface {v2}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, [Ljava/lang/String;

    .local v0, arr$:[Ljava/lang/String;
    array-length v7, v0

    .local v7, len$:I
    const/4 v6, 0x0

    .local v6, i$:I
    :goto_1
    if-ge v6, v7, :cond_3

    aget-object v11, v0, v6

    .line 86
    .local v11, value:Ljava/lang/String;
    new-instance v12, Lnet/oauth/OAuth$Parameter;

    invoke-direct {v12, v9, v11}, Lnet/oauth/OAuth$Parameter;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v8, v12}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 85
    add-int/lit8 v6, v6, 0x1

    goto :goto_1

    .line 89
    .end local v0           #arr$:[Ljava/lang/String;
    .end local v1           #e:Ljava/lang/Object;
    .end local v2           #entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;[Ljava/lang/String;>;"
    .end local v6           #i$:I
    .end local v7           #len$:I
    .end local v9           #name:Ljava/lang/String;
    .end local v11           #value:Ljava/lang/String;
    :cond_4
    return-object v8
.end method


# virtual methods
.method public getBodyAsStream()Ljava/io/InputStream;
    .locals 1
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 47
    iget-object v0, p0, Lnet/oauth/server/HttpRequestMessage;->request:Ljavax/servlet/http/HttpServletRequest;

    invoke-interface {v0}, Ljavax/servlet/http/HttpServletRequest;->getInputStream()Ljavax/servlet/ServletInputStream;

    move-result-object v0

    return-object v0
.end method

.method public getBodyEncoding()Ljava/lang/String;
    .locals 1

    .prologue
    .line 52
    iget-object v0, p0, Lnet/oauth/server/HttpRequestMessage;->request:Ljavax/servlet/http/HttpServletRequest;

    invoke-interface {v0}, Ljavax/servlet/http/HttpServletRequest;->getCharacterEncoding()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method
